package com.example.tbag.healthcare.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.tbag.healthcare.Model.Cache;
import com.example.tbag.healthcare.R;

import java.util.List;

/**
 * Created by tbag on 2017/4/21.
 */

public class MedecineListAdapter extends BaseAdapter {
    private List<Cache> humanInfos;
    private LayoutInflater mInflater;
    private Context context;
    
    public MedecineListAdapter(List<Cache> list, Context context){
        humanInfos = list;
        mInflater = LayoutInflater.from(context);
        this.context = context;
    }
    
    
    @Override
    public int getCount() {
        return humanInfos.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.layout_medecine_list, null);
            holder = new ViewHolder();
            holder.name = (TextView) convertView.findViewById(R.id.edit1);
            holder.sex = (TextView) convertView.findViewById(R.id.edit2);
            convertView.setTag(holder); //绑定ViewHolder对象
        }
        else {
            holder = (ViewHolder) convertView.getTag(); //取出ViewHolder对象
        }
        final Cache humanInfo = humanInfos.get(position);
        holder.name.setText(humanInfo.title);
        holder.sex.setText(humanInfo.money);
        return convertView;
    }

    public final class ViewHolder {
        public TextView name;
        public TextView sex;
       
    }
}
